package com.h2.gwt.util;

import com.google.gwt.text.shared.AbstractRenderer;

public class UIUtils {
   
   public static class ObjectRenderer<T> extends
         AbstractRenderer<T> {
      
      private String _emptyValue = "";
      
      @Override
      public String render(T object) {
          if (object == null) {
             return _emptyValue;
          }
          return object.toString();
      }
      
      public void setEmptyValue(String emptyValue) {
          this._emptyValue = emptyValue;
      }
   
   }

   public static class EnumRenderer<T extends Enum<?>> extends
         AbstractRenderer<T> {

      private String _emptyValue = "";

      @Override
      public String render(T object) {
          if (object == null) {
             return _emptyValue;
          }
          return object.toString();
      }

      public void setEmptyValue(String emptyValue) {
          this._emptyValue = emptyValue;
      }

   }
   
   public static class StringRenderer extends
         AbstractRenderer<String> {
      
      private String _emptyValue = "";
      
      @Override
      public String render(String object) {
          if (object == null) {
             return _emptyValue;
          }
          return object;
      }
      
      public void setEmptyValue(String emptyValue) {
          this._emptyValue = emptyValue;
      }
      
   }
}
